//
//  GCDTaskQueue.h
//  TestApp
//
//  Created by lianglibaoM2 on 2024/8/2.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, GCDTaskPriority) {
    GCDTaskPriorityLow,
    GCDTaskPriorityNormal,
    GCDTaskPriorityHigh
};

@interface GCDTask : NSObject

@property (nonatomic, strong) void (^taskBlock)(void);
@property (nonatomic, assign) GCDTaskPriority priority;
@property (nonatomic, assign, getter=isCancelled) BOOL cancelled;

- (instancetype)initWithBlock:(void (^)(void))block priority:(GCDTaskPriority)priority;
- (void)addDependency:(GCDTask *)task;
- (void)cancel;

@end

@interface GCDTaskQueue : NSObject

@property (nonatomic, assign) NSInteger maxConcurrentTasks;

- (void)addTask:(GCDTask *)task;
- (void)start;
- (void)cancelAllTasks;

@end

NS_ASSUME_NONNULL_END
